<style lang="less">
.van-tab {
    color: #1AAD00;
    font-size: 0.8rem;
}
.van-tabs__line {
    background-color: #1AAD00;
}
.btn_status1 {
	color: #F09951;
}
.btn_status2 {
	color: #2AC50F;
}
.btn_status3 {
	color: #FF5757;
}
.xs_list .van-cell .van-cell__title .van-cell-text {
	width: 60%;
}
.shenhe .boxheights{
	overflow: hidden;
	overflow-y: auto;
	border: 1px solid red;
}
</style>

<template>
	<mxq-router-layout>
		<div class="shenhe">
			<Head slot="header" @headerClick="headerClick($event)">
				<div slot="headerTitle">
					审核管理
				</div>
				<div slot="headerRight">
					<i class="iconfont icon-shouye"/>
					<!--<van-icon class="home" name="home"/>-->
				</div>
			</Head>
			<van-tabs v-model="active" sticky  @click="onClick">
				<van-tab :title="DbNum" >
					<XsList
						:list="taskLists"
						:listLeftImg="listLeftImg"
						:listTitle="listTitle"
						@listClick="listClick($event)"/>
				</van-tab>
				<van-tab :title="YbNum">
					<XsList
						:list="taskLists2"
						:listLeftImg="listLeftImg"
						:listTitle="listTitle2"
						@listClick="listClick($event)"/>
				</van-tab>
			</van-tabs>
		</div>
	</mxq-router-layout>
</template>

<script>
import Head from '../../components/head';
import XsList from '../../components/xs-list';
import { callData } from '../../axios/axios';
import IconYin from '../../assets/img/changguixunshi/icon_yin.png';
import IconQue from '../../assets/img/changguixunshi/icon_que.png';
import {
    Icon,
    Tab,
	Tabs,
	List,
	Toast
} from 'vant'

export default {
    name: 'shenhe',
    components: {
        Head,
        XsList,
        [Icon.name]:Icon,
        [Tab.name]:Tab,
		[Tabs.name]:Tabs,
		[List.name]:List,
		[Toast.name]:Toast
    },
    data() {
		return {
			boxheight2: (window.innerHeight*1 - 95)+'px',
			boxheight: (window.innerHeight*1 - 55)+'px',
			YbNum: "已审核（0）",
			DbNum: "待审核（0）",
            active: 0,
			taskLists:[],
			taskLists2:[],
			listLeftImg: [IconQue,IconYin],
			listTitle: ['缺陷类别：','上报时间：'],
			listTitle2: ['隐患类别：','上报时间：']
		}
	},
    methods: {
        onClickRight(e){
			this.$router.push({
				path:'/index'
			})
		},
		// 头部两侧按钮点击事件
        headerClick(e){
			this.$router.push({name:'index'})
        },
        // 
        onClick(index, title) {
        		if(index == 0) this.onLoadDB()
        		else this.onLoadYB()
		},
		listClick(e){
			let query = {
				id: e.data.id,
				type: e.data.status == 1 ? e.data.status: "",
				reviewId: e.data.reviewId,
				isYhOrDefect: e.data.isYhOrDefect,
				lbid: e.data.lbid,
				active: this.active,
				qxTypeName: e.data.qxTypeName
			}
			if(e.data.isYhOrDefect == 1){
				this.$router.push({
					name: 'shenhe_yhDetail',
					id: e.towId,
					query: query
				})
			}else{
				this.$router.push({
					name: 'shenhe_qxDetail',
					id: e.towId,
					query: query
				})
			}
		},
		// 待办数据加载
		onLoadDB() {
			let param = {}
				param.page = 0
				param.size = 100
				param.status = 0
			this.getListData(1,param)
		},
		// 已办数据加载
		onLoadYB() {
			let param = {}
				param.page = 0
				param.size = 100
				param.status = 1
			this.getListData(2,param)
		},
		// 拿到代办|已办的数据
		getListData(type,param){
			this.getNumberData()
			let listArr = []
			callData('/accountServer/YhDefectCheck/findYhDefect', 'get', param).then(res => {
				if(res.success){
					let data = res.data.content
					let dataArr = []
					data.forEach((item,index) => {
						let items = {}
							items.mdzz =  item.TYPE
							items.gtnum =  item.CREATE_TIME
							items.status = item.TYPE
							items.line = "【"+item.TYPE_NAME+"】"+item.LINE_NAME_PY+"_"+item.TOWER_NAME
							items.id = item.ID
							items.reviewId  = item.REVIEW_ID
							items.isYhOrDefect = item.TYPE
							items.lbid = item.LBID
							items.statusName = item.REVIEW_TYPE == 0 ? "复核": item.REVIEW_TYPE == 1?"消缺": item.REVIEW_TYPE == 2?"新增":"新增"
							items.cname = item.REVIEW_TYPE == 0 ? "btn_status1": item.REVIEW_TYPE == 1?"btn_status3": item.REVIEW_TYPE == 2?"btn_status2":"btn_status2"
							items.cname1 = item.REVIEW_TYPE == 0 ? "btn_statusNo": item.REVIEW_TYPE == 1?"btn_statusNo": item.REVIEW_TYPE == 2?"btn_statusNo":"btn_statusNo"
							items.qxTypeName = item.TYPE_NAME
						listArr.push(items)
					})
				}
			})
			if(type == 1){
				this.taskLists = listArr
			}else{
				this.taskLists2 = listArr
			}
		},
		getNumberData(){
			let param = {}
			let _this = this
			callData('/accountServer/YhDefectCheck/setCmDefectApprovalNumber', 'get', param).then(res => {
				if(res.success){
					let data = res.data
					_this.YbNum = '已审核（'+data.YSH+'）'
					_this.DbNum = '待审核（'+data.DSH+'）'
				}
			})
		}
	},
    mounted() {
        this.onLoadDB()
    }
}
</script>

